﻿package mortal.game.resource
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;

    public class FuncPreCofonfig extends Object
    {
        private var _dic:Dictionary;
        private var arr:Array;
        private var _tipsTextCodes:Dictionary;
        private static var _instance:FuncPreCofonfig;
        public static var guideCodes:Object;

        public function FuncPreCofonfig()
        {
            this._dic = new Dictionary();
            this.arr = [];
            this._tipsTextCodes = new Dictionary();
            this.init();
            return;
        }// end function

        public function isTextTips(param1:int) : Boolean
        {
            return this._tipsTextCodes[param1] != null;
        }// end function

        private function init() : void
        {
            var _loc_2:Object = null;
            var _loc_3:TSystemTrailer = null;
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_system_trailer.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new TSystemTrailer();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._dic[_loc_3.level] = _loc_3;
                this.arr.push(_loc_3);
            }
            guideCodes = AutoGuideConfig.instance.getGuideCodes_TaskGuide();
            this._tipsTextCodes[104] = true;
            this._tipsTextCodes[105] = true;
            this._tipsTextCodes[106] = true;
            this._tipsTextCodes[110] = true;
            this._tipsTextCodes[112] = true;
            this._tipsTextCodes[115] = true;
            this._tipsTextCodes[119] = true;
            this._tipsTextCodes[120] = true;
            this._tipsTextCodes[121] = true;
            this._tipsTextCodes[122] = true;
            this._tipsTextCodes[123] = true;
            this._tipsTextCodes[124] = true;
            this._tipsTextCodes[125] = true;
            return;
        }// end function

        public function hasGuideSystemInAutoGuide(param1:String) : Boolean
        {
            return guideCodes[param1] != null;
        }// end function

        public function getConfig(param1:int) : TSystemTrailer
        {
            var _loc_2:TSystemTrailer = null;
            for each (_loc_2 in this.arr)
            {
                
                if (_loc_2.code == param1)
                {
                    return _loc_2;
                }
            }
            return null;
        }// end function

        public function getConfigBySystem(param1:String) : TSystemTrailer
        {
            var _loc_2:TSystemTrailer = null;
            for each (_loc_2 in this.arr)
            {
                
                if (_loc_2.system == param1)
                {
                    return _loc_2;
                }
            }
            return null;
        }// end function

        public function getNextFuncPreView(param1:int) : TSystemTrailer
        {
            var _loc_3:TSystemTrailer = null;
            var _loc_4:* = undefined;
            var _loc_5:int = 0;
            var _loc_6:TSystemTrailer = null;
            var _loc_7:int = 0;
            var _loc_2:* = int.MAX_VALUE;
            for (_loc_4 in this._dic)
            {
                
                _loc_5 = int(_loc_4);
                _loc_6 = this._dic[_loc_4];
                if (_loc_5 > param1)
                {
                    if (_loc_5 <= _loc_2)
                    {
                        _loc_2 = _loc_5;
                        _loc_3 = _loc_6;
                    }
                    continue;
                }
                if (_loc_5 == param1)
                {
                    _loc_7 = int(guideCodes[_loc_6.system.toString()]);
                    if (_loc_7 > 0 && !GameController.autoGuide.hasGuideMainId(_loc_7))
                    {
                        return _loc_6;
                    }
                }
            }
            return _loc_3;
        }// end function

        public static function get instance() : FuncPreCofonfig
        {
            if (_instance == null)
            {
                _instance = new FuncPreCofonfig;
            }
            return _instance;
        }// end function

    }
}
